<?php

class InstallController extends Controller
{
    public function actionIndex()
    {
        $sql="
                CREATE TABLE IF NOT EXISTS `sliderBanner` (
                `id` int(11) NOT NULL AUTO_INCREMENT,
                `title` varchar(255) NOT NULL DEFAULT '',
                `image` varchar(255) NOT NULL,
                `type` varchar(50) NOT NULL DEFAULT '',
                `image_link` varchar(255) NOT NULL DEFAULT '',
                `image_link_target` varchar(20) NOT NULL DEFAULT '',
                `info_text` varchar(255) NOT NULL DEFAULT '',
                `info_text_link` varchar(255) NOT NULL DEFAULT '',
                `info_text_link_title` varchar(100) NOT NULL DEFAULT '',
                `info_text_link_target` varchar(20) NOT NULL DEFAULT '',
                `sort` int(11) NOT NULL DEFAULT '0',
                `is_active` tinyint(4) NOT NULL DEFAULT 1,
                PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
             ";

        $db=Yii::app()->db;
        $db->createCommand($sql)->query();

        $error=implode(' ',$db->stats);

        if($error=='0 0'){
            $text=Yii::t('modules/main','installOkMessage',array(
                '{module}'=>'Slider',
            ));
        }else{
            $text=Yii::t('modules/main','installErrorMessage',array(
                '{module}'=>'Slider',
                '{error}'=>$error,
            ));
        }
        $this->render('index',array(
            'text'=>$text,
        ));
    }
}